import { combineReducers } from 'redux'
import { INCREASE, DESCREASE } from './action';

// 1. 设计 state
const initialState = {
	value: 0
};

// 2. 根据 state 结构, 编写子 reducer
function value(state = 0, action) {
	switch(action.type) {
		case INCREASE:
			return state + 1;
		case DESCREASE:
			return state - 1;
		default:
			return state;
	}
}

// 3. 合并子 reducer
const counterReducer = combineReducers({
	value
});

// 4. 暴露 root reducer
export default counterReducer;
